package com.app.business.web.business;

import com.app.business.en.HouseStatus;
import com.app.business.model.*;
import com.app.business.service.*;
import com.app.system.jpa.PageBean;
import com.app.system.log4j2.LogUtils;
import com.app.system.permission.model.DataDict;
import com.app.system.permission.service.DataDictService;
import com.app.system.utils.CollectionUtils;
import com.app.system.utils.ParamUtils;
import com.app.system.utils.dataType.BigDecimalUtils;
import com.app.system.utils.dataType.DateUtils;
import com.app.system.utils.dataType.StringUtils;
import com.app.system.utils.exception.Precondition;
import com.app.system.utils.page.LayUiUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import freemarker.template.Configuration;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 征收项目所属房源查看
 * Created by ddz on 2019/3/14.
 */
@Controller
@RequestMapping("/business/zsProjectHouseView/*")
@SuppressWarnings("all")
public class ZsProjectHouseViewController {
    @Resource
    private ZsProjectService zsProjectService;
    @Resource
    private HouseService houseService;
    @Resource
    private DataDictService dataDictService;
    @Resource
    private ZsProjectHouseService zsProjectHouseService;
    @Resource
    private AzProjectService azProjectService;
    @Resource
    private StorageRoomService storageRoomService;
    @Resource
    private CarLotService carLotService;
    @Resource
    private BuyHousePersonService buyHousePersonService;
    @Resource
    private HouseBuyPersonService houseBuyPersonService;
    @Resource
    private CarLotBuyPersonService carLotBuyPersonService;
    private Logger logger = LogUtils.getBusinessLogger();

    @Autowired
    private Configuration freemarkerConfiguration; // 注入bean，这里是属性注入，推荐构造注入


    /**
     * 征收项目数据列表
     */
    @RequestMapping("zsProjectList")
    @RequiresPermissions("zsProjectHouseView:zsProjectList")
    public void list() {
    }

    /**
     * 加载征收项目数据
     *
     * @return
     */
    @RequestMapping("loadZsProjectList")
    @ResponseBody
    @RequiresPermissions("zsProjectHouseView:loadZsProjectList")
    public Map loadFamilyList() {
        List<Map> listData = Lists.newArrayList();
        PageBean<ZsProject> zsProjectPageBean = this.zsProjectService.getZsProjectPageBean();
        List<ZsProject> zsProjectList = zsProjectPageBean.getDatas();
        Map<String, String> townMap = dataDictService.getMapByParentNameForValue_Name("乡镇");
        if (!CollectionUtils.isEmpty(zsProjectList)) {
            Map<String, Object> item = null;
            for (ZsProject zsProject : zsProjectList) {
                item = Maps.newHashMap();
                item.put("id", zsProject.getId());
                item.put("town", StringUtils.getNotNull(townMap.get(zsProject.getTown())));
                item.put("projectCode", StringUtils.getNotNull(zsProject.getProjectCode()));
                item.put("projectName", StringUtils.getNotNull(zsProject.getProjectName()));
                item.put("startYear", DateUtils.dateToStringDefault(zsProject.getStartYear()));
                item.put("memo", StringUtils.getNotNull(zsProject.getMemo()));
                listData.add(item);
            }
        }
        return LayUiUtils.page(zsProjectPageBean.getTotalCount().intValue(), listData);
    }

    /**
     * 住宅房源数据管理列表
     */
    @RequestMapping("houseList")
    @RequiresPermissions("house:houseList")
    public void houseList(HttpServletRequest request, ModelMap modelMap) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        ZsProject zsProject = this.zsProjectService.findOne(zsProjectId);
        modelMap.addAttribute("zsProjectId", zsProjectId);
    }

    /**
     * 加载房源信息数据
     *
     * @return
     */
    @RequestMapping("loadHouseList")
    @ResponseBody
    @RequiresPermissions("house:loadHouseList")
    public Map loadHouseList(HttpServletRequest request) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        String buildAreaStr = ParamUtils.getString(request, "buildAreaStr", "0");
        BigDecimal buildArea = BigDecimalUtils.stringToBigDecimal(buildAreaStr);
        List<Map> listData = Lists.newArrayList();
        PageBean<House> housePageBean = this.houseService.getHouseListByZsProjectIdAndBuildArea(zsProjectId, buildArea);
        List<House> houseList = housePageBean.getDatas();
        Map<String, DataDict> houseTypeMap = this.dataDictService.getMapByParentNameForValue("房屋类型");
        Map<String, DataDict> houseStatusMap = this.dataDictService.getMapByParentNameForValue("房源状态");
        Map<String, DataDict> houseHoldMap = this.dataDictService.getMapByParentNameForValue("房屋户型");
        if (!CollectionUtils.isEmpty(houseList)) {
            Map<String, Object> item = null;
            for (House house : houseList) {
                item = null;
                item = Maps.newHashMap();
                item.put("id", house.getId());
                item.put("azProjectName", StringUtils.getNotNull(house.getAzProject().getProjectName()));
                item.put("buildNum", StringUtils.getNotNull(house.getBuildNum()));
                item.put("houseNum", StringUtils.getNotNull(house.getHouseNum()));
                item.put("houseStyle", StringUtils.getNotNull(house.getHouseStyle()));
                item.put("memo", StringUtils.getNotNull(house.getMemo()));
                item.put("floor", house.getFloor());
                item.put("houseTypeStr", StringUtils.dataDictShow(houseTypeMap.get(house.getHouseType())));
                item.put("houseHoldStr", StringUtils.dataDictShow(houseHoldMap.get(house.getHouseHold())));
                item.put("propertyArea", BigDecimalUtils.getNotNullStr(house.getPropertyArea()));
                item.put("poolArea", BigDecimalUtils.getNotNullStr(house.getPoolArea()));
                item.put("buildArea", BigDecimalUtils.getNotNullStr(house.getBuildArea()));
                item.put("houseStatus", house.getHouseStatus());
                item.put("houseStatusStr", StringUtils.dataDictShow(houseStatusMap.get(house.getHouseStatus().toString())));
                item.put("chooseHouseDate", DateUtils.dateToStringDefault(house.getChooseHouseDate()));
                listData.add(item);
            }
        }
        return LayUiUtils.page(housePageBean.getTotalCount().intValue(), listData);
    }

    /**
     * 房源信息导出
     */
    @RequestMapping("houseListExcel")
    @RequiresPermissions("house:houseListExcel")
    public void houseListExcel(HttpServletRequest request, HttpServletResponse response) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        String buildAreaStr = ParamUtils.getString(request, "buildAreaStr", "0");
        BigDecimal buildArea = BigDecimalUtils.stringToBigDecimal(buildAreaStr);
        PageBean<House> housePageBean = this.houseService.getHouseExcelListByZsProjectIdAndBuildArea(zsProjectId, buildArea);

        List<House> houseList = housePageBean.getDatas();
        Map<String, DataDict> houseHoldMap = this.dataDictService.getMapByParentNameForValue("房屋户型");
        Map<String, DataDict> houseTypeMap = this.dataDictService.getMapByParentNameForValue("房屋类型");
        Map<String, DataDict> houseStatusMap = this.dataDictService.getMapByParentNameForValue("房源状态");
        try {
            // 封装导出数据
            Map data = Maps.newHashMap();
            data.put("houseList", houseList);
            data.put("houseHoldMap", houseHoldMap);
            data.put("houseTypeMap", houseTypeMap);
            data.put("houseStatusMap", houseStatusMap);
            data.put("exportPerson", SecurityUtils.getSubject().getPrincipal());   //导出人姓名
            data.put("exportTime", DateUtils.dateToStringFormat(new Date(), "yyyy-MM-dd HH:mm:ss"));   //导出时间
//            data.put("decisions", exportDecisionList); //第二个worksheet的数据对象
            request.setCharacterEncoding("UTF-8");
            response.setContentType("application/x-download;");
            response.setHeader("Content-disposition", "attachment; filename=" + new String(("房源数据导出.xls").getBytes(), "iso-8859-1"));
            freemarkerConfiguration.getTemplate("/business/zsProjectHouseView/houseListExcel.ftl").process(data, response.getWriter());
        } catch (Exception e) {
            logger.error("文件下载异常", e);
            e.printStackTrace();
        }
    }


    /**
     * 房源分配查看
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("houseTree")
    @RequiresPermissions("zsProjectHouseView:houseTree")
    public void housePicture(HttpServletRequest request, ModelMap modelMap) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        ZsProject zsProject = zsProjectService.findOne(zsProjectId);
        Precondition.checkSqdsArguement(zsProject != null, "分配的征收项目不存在");
        modelMap.addAttribute("zsProject", zsProject);
    }

    /**
     * 获取树形菜单
     *
     * @return
     */
    @RequestMapping("loadTreeData")
    @ResponseBody
    @RequiresPermissions("zsProjectHouseView:loadTreeData")
    public Map loadTreeData(HttpServletRequest request) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        List<Map> childrenList = this.houseService.mapTreeDataForView(zsProjectId);
        Map map = Maps.newLinkedHashMap();
        map.put("id", null);
        map.put("name", "安置项目");
        map.put("spread", true);
        map.put("children", childrenList);

        return map;

    }

    /**
     * 加载楼盘图
     *
     * @param request
     * @return
     */
    @RequestMapping("loadHousePicture")
    @ResponseBody
    @RequiresPermissions("zsProjectHouseView:loadHousePicture")
    public Map loadHousePicture(HttpServletRequest request) {
        Integer azProjectId = ParamUtils.getInt(request, "azProjectId", 0);
        String buildNum = ParamUtils.getString(request, "buildNum", "");
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);

        //查出所有房源
        List<House> houseList = houseService.houseList(zsProjectId.toString(), azProjectId, buildNum);

        //得到层号和当前楼层的List<House>对应的map
        Map<String, List<House>> floorHouseMap = houseService.getFloorHouseMap(houseList);

        //房源状态
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("房源状态");
        //房屋类型
        Map<String, String> houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");
        //得到征收项目某栋楼中已经分配的房源
        Map<String, String> houseIdMap = zsProjectHouseService.getHouseIdMap(zsProjectId, azProjectId, buildNum);

        Map<String, Integer> maxFloorMap = houseService.getMaxFloorMap(zsProjectId.toString(), azProjectId, buildNum);
        Integer maxFloor = maxFloorMap.get("maxFloor");

        AzProject azProject = azProjectService.findOne(azProjectId);

        Map<String, Object> map = Maps.newHashMap();
        map.put("maxFloor", maxFloor);
        map.put("floorHouseMap", floorHouseMap);
        map.put("colorMap", colorMap);
        map.put("houseHoldMap", houseHoldMap);
        map.put("houseIdMap", houseIdMap);
        map.put("azProject", azProject);
        return map;
    }


    /**
     * 房屋结构类型详情
     *
     * @param request
     * @return
     */
    @RequestMapping("houseHoldInfo")
    @ResponseBody
    @RequiresPermissions("zsProjectHouseView:houseHoldInfo")
    public Map houseTypeInfo(HttpServletRequest request) {
        Integer azProjectId = ParamUtils.getInt(request, "azProjectId", 0);
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        String buildNum = ParamUtils.getString(request, "buildNum", "");
        Map<String, String> houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");
        Map<String, Map> houseInfoMap = this.houseService.houseHoldInfoMap(zsProjectId, azProjectId, buildNum);
        Map houseHoldTotalMap = this.houseService.houseHoldTotalMap(zsProjectId, azProjectId, buildNum);
        Map<String, Object> map = Maps.newHashMap();
        map.put("houseHoldMap", houseHoldMap);
        map.put("houseInfoMap", houseInfoMap);
        map.put("houseHoldTotalMap", houseHoldTotalMap);
        return map;
    }


    /**
     * 征收项目数据查看
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("houseView")
    @RequiresPermissions("zsProjectHouseView:houseView")
    public void houseView(HttpServletRequest request, ModelMap modelMap) {
        int houseId = ParamUtils.getInt(request, "houseId", 0);
        House house = this.houseService.findOne(houseId);
        Precondition.checkSqdsArguement(house != null, "数据错误！");
        AzProject azProject = this.azProjectService.findOne(house.getAzProject().getId());
        Precondition.checkSqdsArguement(azProject != null, "数据错误！");
        Map<String, DataDict> houseTypeMap = this.dataDictService.getMapByParentNameForValue("房屋类型");
        Map<String, DataDict> houseHoldMap = this.dataDictService.getMapByParentNameForValue("房屋户型");
        Map<String, DataDict> carLotTypeMap = this.dataDictService.getMapByParentNameForValue("车位类型");
        Map<String, StorageRoom> resultMap = Maps.newHashMap();
        if (house.getContract() != null) {
            Integer contractId = house.getContract().getId();
            List<House> houseList = this.houseService.getHouseListByContractId(contractId);
            modelMap.addAttribute("houseList", houseList);
            List<StorageRoom> storageRoomList = this.storageRoomService.getStorageRoomListByContractId(contractId);
            modelMap.addAttribute("storageRoomList", storageRoomList);
            List<CarLot> carLotList = this.carLotService.getCarLotListByContractId(contractId);
            modelMap.addAttribute("carLotList", carLotList);
            List<String> ids = this.houseBuyPersonService.getBuyHousePersonIdListByHouseId(house.getId());
            List<BuyHousePerson> buyHousePersonList = new ArrayList<>();
            if (ids.size() != 0) {
                buyHousePersonList = this.buyHousePersonService.getBuyHousePersonListByBuyHousePersonId(ids, contractId);
            }
            modelMap.addAttribute("buyHousePersonList", buyHousePersonList);
            resultMap = Maps.newHashMap();
            List<Integer> houseIdList = Lists.newArrayList();
            houseIdList.add(house.getId());
            resultMap = this.storageRoomService.getStorageRoomMap(houseIdList);
        }

        modelMap.addAttribute("azProject", azProject);
        modelMap.addAttribute("house", house);
        modelMap.addAttribute("houseTypeMap", houseTypeMap);
        modelMap.addAttribute("houseHoldMap", houseHoldMap);
        modelMap.addAttribute("carLotTypeMap", carLotTypeMap);
        modelMap.addAttribute("resultMap", resultMap);
    }

    /**
     * 查看储物间列表
     */
    @RequestMapping("storageRoomList")
    @RequiresPermissions("zsProjectHouseView:storageRoomList")
    public void storageRoom(HttpServletRequest request, ModelMap modelMap) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        ZsProject zsProject = this.zsProjectService.findOne(zsProjectId);
        Precondition.checkSqdsArguement(zsProject != null, "数据错误！未找到征收项目!");
        List<String> azProjectIdList = this.houseService.getAzProjectIdListByZsProjectId(zsProjectId);
        List<AzProject> azProjectList = this.azProjectService.azProjectListByAzProjectIdList(azProjectIdList);
        modelMap.addAttribute("zsProject", zsProject);
        modelMap.addAttribute("azProjectList", azProjectList);
    }

    /**
     * 加载储物间数据
     *
     * @return
     */
    @RequestMapping("loadStorageRoomList")
    @ResponseBody
    @RequiresPermissions("zsProjectHouseView:loadStorageRoomList")
    public Map loadStorageRoomList(HttpServletRequest request) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        ZsProject zsProject = this.zsProjectService.findOne(zsProjectId);
        Precondition.checkSqdsArguement(zsProject != null, "数据错误！未找到征收项目!");
        List<Map> resultData = Lists.newArrayList();
        //得到该征收项目所分配的安置项目所有的车位
        PageBean<StorageRoom> pageBean = this.storageRoomService.getStorageRoomPageByZsProjectId(zsProject.getId());

        Map<String, DataDict> houseStatusMap = this.dataDictService.getMapByParentNameForValue("房源状态");
        if (CollectionUtils.isNotEmpty(pageBean.getDatas())) {
            Map<String, Object> mapItem = null;
            Integer houseStatus = null;
            for (StorageRoom storageRoom : pageBean.getDatas()) {
                mapItem = null;
                houseStatus = null;
                mapItem = Maps.newHashMap();
                mapItem.put("id", storageRoom.getId());
                mapItem.put("projectName", storageRoom.getAzProject().getProjectName());
                mapItem.put("buildNum", storageRoom.getBuildNum());
                mapItem.put("houseNum", storageRoom.getHouseNumStr());
                mapItem.put("floor", storageRoom.getFloor());
                mapItem.put("buildArea", storageRoom.getBuildArea());
                mapItem.put("houseStatus", storageRoom.getHouseStatus());
                //如果是预留的，则显示为已选状态
                houseStatus = storageRoom.getHouseStatus().equals(HouseStatus.YULIU.getIndex()) ? HouseStatus.YIXUAN.getIndex() : storageRoom.getHouseStatus();
                mapItem.put("houseStatusStr", StringUtils.dataDictShow(houseStatusMap.get(houseStatus.toString())));
                resultData.add(mapItem);
            }
        }
        return LayUiUtils.page(pageBean.getTotalCount().intValue(), resultData);
    }

    /**
     * 储物间详情查看
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("storageRoomView")
    @RequiresPermissions("zsProjectHouseView:storageRoomView")
    public void storageRoomView(HttpServletRequest request, ModelMap modelMap) {
        int storageRoomId = ParamUtils.getInt(request, "storageRoomId", 0);
        StorageRoom storageRoom = this.storageRoomService.findOne(storageRoomId);
        AzProject azProject = this.azProjectService.findOne(storageRoom.getAzProject().getId());
        Precondition.checkSqdsArguement(azProject != null, "数据错误！");
        Precondition.checkSqdsArguement(storageRoom != null, "数据错误！");
        Map<String, DataDict> houseTypeMap = this.dataDictService.getMapByParentNameForValue("房屋类型");
        Map<String, DataDict> carLotTypeMap = this.dataDictService.getMapByParentNameForValue("车位类型");
        if (storageRoom.getHouse() != null) {
            Integer houseId = storageRoom.getHouse().getId();
            House house = this.houseService.findOne(houseId);
            modelMap.addAttribute("house", house);

            List<String> ids = this.houseBuyPersonService.getBuyHousePersonIdListByHouseId(houseId);
            List<BuyHousePerson> buyHousePersonList = new ArrayList<>();
            if (ids.size() != 0) {
                buyHousePersonList = this.buyHousePersonService.getBuyHousePersonListByBuyHousePersonId(ids, storageRoom.getContract().getId());
            }
            modelMap.addAttribute("buyHousePersonList", buyHousePersonList);
        }
        if (storageRoom.getContract() != null) {
            Integer contractId = storageRoom.getContract().getId();
            List<House> houseList = this.houseService.getHouseListByContractId(contractId);
            modelMap.addAttribute("houseList", houseList);
            List<StorageRoom> storageRoomList = this.storageRoomService.getStorageRoomListByContractId(contractId);
            modelMap.addAttribute("storageRoomList", storageRoomList);
            List<CarLot> carLotList = this.carLotService.getCarLotListByContractId(contractId);
            modelMap.addAttribute("carLotList", carLotList);
        }
        modelMap.addAttribute("azProject", azProject);
        modelMap.addAttribute("storageRoom", storageRoom);
        modelMap.addAttribute("houseTypeMap", houseTypeMap);
        modelMap.addAttribute("carLotTypeMap", carLotTypeMap);
    }


    /**
     * 查看车位列表
     */
    @RequestMapping("carLotList")
    @RequiresPermissions("zsProjectHouseView:carLotList")
    public void carLotList(HttpServletRequest request, ModelMap modelMap) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        ZsProject zsProject = this.zsProjectService.findOne(zsProjectId);
        Precondition.checkSqdsArguement(zsProject != null, "数据错误！未找到征收项目!");
        modelMap.addAttribute("zsProject", zsProject);
    }

    /**
     * 加载车位数据
     *
     * @return
     */
    @RequestMapping("loadCarLotList")
    @ResponseBody
    @RequiresPermissions("zsProjectHouseView:loadCarLotList")
    public Map loadCarLotList(HttpServletRequest request) {
        Integer zsProjectId = ParamUtils.getInt(request, "zsProjectId", 0);
        ZsProject zsProject = this.zsProjectService.findOne(zsProjectId);
        Precondition.checkSqdsArguement(zsProject != null, "数据错误！未找到征收项目!");
        List<Map> resultData = Lists.newArrayList();
        //得到该征收项目所分配的安置项目所有的车位
        PageBean<CarLot> pageBean = this.carLotService.getCarLotPageByZsProjectId(zsProject.getId());

        Map<String, DataDict> houseStatusMap = this.dataDictService.getMapByParentNameForValue("房源状态");
        Map<String, DataDict> carLotTypeMap = this.dataDictService.getMapByParentNameForValue("车位类型");
        if (CollectionUtils.isNotEmpty(pageBean.getDatas())) {
            Map<String, Object> mapItem = null;
            Integer houseStatus = null;
            for (CarLot carLot : pageBean.getDatas()) {
                mapItem = null;
                houseStatus = null;
                mapItem = Maps.newHashMap();
                mapItem.put("id", carLot.getId());
                mapItem.put("projectName", carLot.getAzProject().getProjectName());
                mapItem.put("buildNum", carLot.getBuildNum());
                mapItem.put("houseNum", carLot.getHouseNumStr());
                mapItem.put("floor", carLot.getFloor());
                mapItem.put("buildArea", carLot.getBuildArea());
                mapItem.put("carLotTypeStr", StringUtils.dataDictShow(carLotTypeMap.get(carLot.getCarLotType().toString())));
                mapItem.put("houseStatus", carLot.getHouseStatus());
                //如果是预留的，则显示为已选状态
                houseStatus = carLot.getHouseStatus().equals(HouseStatus.YULIU.getIndex()) ? HouseStatus.YIXUAN.getIndex() : carLot.getHouseStatus();
                mapItem.put("houseStatusStr", StringUtils.dataDictShow(houseStatusMap.get(houseStatus.toString())));
                resultData.add(mapItem);
            }
        }
        return LayUiUtils.page(pageBean.getTotalCount().intValue(), resultData);
    }

    /**
     * 车位信息查看
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("carLotView")
    @RequiresPermissions("zsProjectHouseView:carLotView")
    public void carLotView(HttpServletRequest request, ModelMap modelMap) {
        int carLotId = ParamUtils.getInt(request, "carLotId", 0);
        CarLot carLot = this.carLotService.findOne(carLotId);
        AzProject azProject = this.azProjectService.findOne(carLot.getAzProject().getId());
        Precondition.checkSqdsArguement(azProject != null, "数据错误！");
        Precondition.checkSqdsArguement(carLot != null, "数据错误！");
        Map<String, DataDict> houseTypeMap = this.dataDictService.getMapByParentNameForValue("房屋类型");
        Map<String, DataDict> carLotTypeMap = this.dataDictService.getMapByParentNameForValue("车位类型");

        if (carLot.getContract() != null) {
            Integer contractId = carLot.getContract().getId();
            List<House> houseList = this.houseService.getHouseListByContractId(contractId);
            modelMap.addAttribute("houseList", houseList);
            List<StorageRoom> storageRoomList = this.storageRoomService.getStorageRoomListByContractId(contractId);
            modelMap.addAttribute("storageRoomList", storageRoomList);
            List<CarLot> carLotList = this.carLotService.getCarLotListByContractId(contractId);
            modelMap.addAttribute("carLotList", carLotList);
            List<String> ids = this.carLotBuyPersonService.getBuyHousePersonIdListByCarLotId(carLot.getId());
            List<BuyHousePerson> buyHousePersonList = new ArrayList<>();
            if (ids.size() != 0) {
                buyHousePersonList = this.buyHousePersonService.getBuyHousePersonListByBuyHousePersonId(ids, contractId);
            }
            modelMap.addAttribute("buyHousePersonList", buyHousePersonList);
        }
        modelMap.addAttribute("azProject", azProject);
        modelMap.addAttribute("carLot", carLot);
        modelMap.addAttribute("houseTypeMap", houseTypeMap);
        modelMap.addAttribute("carLotTypeMap", carLotTypeMap);
    }
}
